package com.gohome.gohomechat.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gohome.gohomechat.R;
import com.gohome.gohomechat.utils.ToActivityUtil;

/**
 * Created by dllo on 16/3/11.
 */
public class CreateGroupActivity extends BaseActivity implements View.OnClickListener {
    private ImageButton creategroup_imgbtn_back;
    private EditText creategroup_groupname, creategroup_groupintro;
    private CheckBox creategroup_ispublic, creategroup_isinvitation;
    private TextView creategroup_title_save;
    private LinearLayout creategroup_isinvitation_layout;


    @Override
    protected int getLayout() {
        return R.layout.activity_cerategroup;
    }

    @Override
    protected void initPresenter() {
    }

    @Override
    protected void initView() {
        creategroup_isinvitation_layout = findView(R.id.creategroup_isinvitation_layout);
        creategroup_imgbtn_back = findView(R.id.creategroup_imgbtn_back);
        creategroup_groupname = findView(R.id.creategroup_groupname);
        creategroup_groupintro = findView(R.id.creategroup_groupintro);
        creategroup_ispublic = findView(R.id.creategroup_ispublic);
        creategroup_isinvitation = findView(R.id.creategroup_isinvitation);
        creategroup_title_save = findView(R.id.creategroup_title_save);
    }

    @Override
    protected void initData() {
        creategroup_imgbtn_back.setOnClickListener(this);
        creategroup_title_save.setOnClickListener(this);
        creategroup_ispublic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked)
                    creategroup_isinvitation_layout.setVisibility(View.GONE);
                else
                    creategroup_isinvitation_layout.setVisibility(View.VISIBLE);

            }
        });
        creategroup_isinvitation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.creategroup_title_save:
                Bundle bundle=new Bundle();
                bundle.putString("groupname",creategroup_groupname.getText().toString().trim());
                bundle.putString("groupintro", creategroup_groupintro.getText().toString().trim());
                bundle.putBoolean("ispublic", creategroup_ispublic.isChecked());
                bundle.putBoolean("isinvitation", creategroup_isinvitation.isChecked());
                ToActivityUtil.startToActivity(this, SelectorContantActivity.class, bundle);

                break;
            case R.id.creategroup_imgbtn_back:
                finish();
                break;
        }
    }


}
